package com.vanke.devops.domain.manager.docker.extend.impl;

import com.github.dockerjava.api.DockerClient;
import com.vanke.devops.domain.manager.docker.extend.DockerClientExtend;
import com.vanke.devops.domain.manager.docker.extend.DockerCmdExecFactoryExtend;
import com.vanke.devops.domain.manager.docker.extend.command.InspectServiceCmd;
import com.vanke.devops.domain.manager.docker.extend.command.ListNodesCmd;
import com.vanke.devops.domain.manager.docker.extend.command.ListServicesCmd;
import com.vanke.devops.domain.manager.docker.extend.command.ListTasksCmd;
import com.vanke.devops.domain.manager.docker.extend.command.impl.InspectServiceCmdImpl;
import com.vanke.devops.domain.manager.docker.extend.command.impl.ListNodesCmdImpl;
import com.vanke.devops.domain.manager.docker.extend.command.impl.ListServicesCmdImpl;
import com.vanke.devops.domain.manager.docker.extend.command.impl.ListTasksCmdImpl;

/**
 * @author 陈景阳
 * @since 2018/6/7
 */
public class DockerClientExtendImpl  implements DockerClientExtend{

    private DockerClient dockerClient;

    private DockerCmdExecFactoryExtend factory;

    public DockerClientExtendImpl(DockerCmdExecFactoryExtend factory, DockerClient dockerClient) {
        this.dockerClient = dockerClient;
        this.factory =factory;
    }

    @Override
    public DockerClient getDockerClient() {
        return dockerClient;
    }

    @Override
    public ListServicesCmd listServicesCmd() {
        return new ListServicesCmdImpl(factory.createListServicesCmdExec());
    }

    @Override
    public InspectServiceCmd inspectServiceCmd() {
        return new InspectServiceCmdImpl(factory.createInspectServiceCmdExec());
    }

    @Override
    public ListTasksCmd listTasksCmd() {
        return new ListTasksCmdImpl(factory.createListTasksCmdExec());
    }

    @Override
    public ListNodesCmd listNodesCmd() {
        return new ListNodesCmdImpl(factory.createListNodesCmdExec());
    }
}
